<template>
	<view>
		<wx-open-launch-weapp id="launch-btn" username="gh_87e8741e177a" path="pages/member/index?contact=1">
			<script type="text/wxtag-template">
		    <!-- <style>.btn { padding: 12px }</style> -->
		    <button class="service">在线客服</button>
		    </script>
			
		</wx-open-launch-weapp>
	</view>
</template>
<script>
	//#ifdef H5
		import wxjs   from '../../jweixin/lib/index.js';
	//#endif
	export default {
		data() {
			return {
				url: getApp().globalData.url,
				static:getApp().globalData.static
			}
		},
		onLoad(e) {
			//#ifdef H5
			// var btn = document.getElementById('launch-btn');
			// btn.addEventListener('launch', function (e) {
			// 	console.log('success');
			// });
			// btn.addEventListener('error', function (e) {
			// 	console.log('fail', e.detail);
			// });
			//#endif
		},
		//#ifdef H5
		created() {
			this.share_server();
		},
		//#endif
		methods: {
			share_server:function()
			{
				var that  = this;
				var site  = window.location.href;
				uni.request({
					url: this.url+"/wechat_share",
					data: {url:site},
					header: {'Content-Type': 'application/json'},
					success: function (res) 
					{
						console.log(res.data);
						wxjs.config({
						  debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
						  appId: res.data.appId,         // 必填，公众号的唯一标识
						  timestamp: res.data.timestamp, // 必填，生成签名的时间戳
						  nonceStr: res.data.nonceStr,   // 必填，生成签名的随机串
						  signature: res.data.signature,        // 必填，签名
						  jsApiList: ['wx-open-launch-weapp'],// 必填，需要使用的JS接口列表
						  openTagList:['wx-open-launch-weapp']
						});
						wxjs.ready(function (res) {
							console.log(res);
						})
						wxjs.error(function(res){
							console.log(res);
						})
					}
				})
			}
		}
	}
</script>

<style>
</style>
